/**
 * The Prophecy
 * java based lightweight texas hold'em poker software base
 * http://code.google.com/p/theprophecy/
 */

package org.poker.prophecy.basedprogs;

import java.util.Vector;

import org.poker.prophecy.core.Card;
import org.poker.prophecy.core.CardInterface;

/**
 * @author bg
 */

public class StartingHands implements CardInterface{

    Vector<PocketCards> cardPairs = new Vector<PocketCards>();
    
    public StartingHands(){
        //soutStartingHandsSortedByCardValue();
        soutStartingHandsSortedBySamBraidsRating();
    }
    
    public void soutStartingHandsSortedBySamBraidsRating(){
        PocketCards pair = null;
        for (int i = 0; i < VALUES.length; i++) {
            for (int j = 0; j < VALUES.length; j++) {
                pair = new PocketCards(new Card(VALUES[i], HEARTS), new Card(VALUES[j], HEARTS), false);
                if (!isContainedInCardPairsConcerningValues(pair)){
                    addToCardPairs(pair);
                }
            }
        }
        for (int i = 0; i < cardPairs.size(); i++) {
            if (StartingHandsAnalysisSamBraids.isPremiumStartingHand(cardPairs.elementAt(i))){
                System.out.println(cardPairs.elementAt(i));
            }
        }
        for (int i = 0; i < cardPairs.size(); i++) {
            if (StartingHandsAnalysisSamBraids.isStrongStartingHand(cardPairs.elementAt(i))){
                System.out.println(cardPairs.elementAt(i));
            }
        }
        for (int i = 0; i < cardPairs.size(); i++) {
            if (StartingHandsAnalysisSamBraids.isDrawingStartingHand(cardPairs.elementAt(i))){
                System.out.println(cardPairs.elementAt(i));
            }
        }
        for (int i = 0; i < cardPairs.size(); i++) {
            if (StartingHandsAnalysisSamBraids.isGarbageStartingHand(cardPairs.elementAt(i))){
                System.out.println(cardPairs.elementAt(i));
            }
        }
        System.out.println("total # of possible starting hands: "+cardPairs.size());
    }
    
    public void soutStartingHandsSortedByCardValue(){
        PocketCards pair = null;
        for (int i = 0; i < VALUES.length; i++) {
            for (int j = 0; j < VALUES.length; j++) {
                pair = new PocketCards(new Card(VALUES[i], HEARTS), new Card(VALUES[j], HEARTS), false);
                if (!isContainedInCardPairsConcerningValues(pair)){
                    addToCardPairs(pair);
                }
            }
        }
        for (int i = 0; i < cardPairs.size(); i++) {
            System.out.println(cardPairs.elementAt(i));
        }
        System.out.println("total # of possible starting hands: "+cardPairs.size());
    }
    
    public static void main(String[] args) {
        new StartingHands();
    }

    public void addToCardPairs(PocketCards cardPair){
        if (!cardPair.getCard1().hasSameValueThan(cardPair.getCard2())){
            PocketCards suitedPair = new PocketCards(cardPair.getCard1(), cardPair.getCard2(), true);
            cardPairs.addElement(suitedPair);
        }
        cardPairs.addElement(cardPair);
    }
    
    public boolean isContainedInCardPairsConcerningValues(PocketCards cardPair){
        for (int i = 0; i < cardPairs.size(); i++) {
            if (cardPairs.elementAt(i).isSameCardsConcerningValues(cardPair)){
                return true;
            }
        }
        return false;
    }
    
}
